package com.htl.线程.重入锁;

import java.util.concurrent.locks.ReentrantLock;

public class Account implements Runnable{

    private static int num;
    private ReentrantLock reentrantLock = new ReentrantLock();


    @Override
    public void run() {
        /** 上锁 */
        reentrantLock.lock();
        num++;
        System.out.println(Thread.currentThread().getName() + "是当前的第" + num + "位访客");
        /** 解锁 */
        reentrantLock.unlock();
    }

}
